package com.ruoyi.culture.controller;

import java.util.List;
import java.io.IOException;
import javax.servlet.http.HttpServletResponse;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.PutMapping;
import org.springframework.web.bind.annotation.DeleteMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
import com.ruoyi.common.log.annotation.Log;
import com.ruoyi.common.log.enums.BusinessType;
import com.ruoyi.common.security.annotation.RequiresPermissions;
import com.ruoyi.culture.domain.CultureProjectComment;
import com.ruoyi.culture.service.ICultureProjectCommentService;
import com.ruoyi.common.core.web.controller.BaseController;
import com.ruoyi.common.core.web.domain.AjaxResult;
import com.ruoyi.common.core.utils.poi.ExcelUtil;

/**
 * 文化评论Controller
 *
 * @author ruoyi
 * @date 2025-04-27
 */
@RestController
@RequestMapping("/projectComment")
public class CultureProjectCommentController extends BaseController
{
    @Autowired
    private ICultureProjectCommentService cultureProjectCommentService;

    /**
     * 查询文化评论列表
     */
    @RequiresPermissions("culture:projectComment:list")
    @GetMapping("/list")
    public AjaxResult list(CultureProjectComment cultureProjectComment)
    {
        List<CultureProjectComment> list = cultureProjectCommentService.selectCultureProjectCommentList(cultureProjectComment);
        return success(list);
    }

    /**
     * 导出文化评论列表
     */
    @RequiresPermissions("culture:projectComment:export")
    @Log(title = "文化评论", businessType = BusinessType.EXPORT)
    @PostMapping("/export")
    public void export(HttpServletResponse response, CultureProjectComment cultureProjectComment)
    {
        List<CultureProjectComment> list = cultureProjectCommentService.selectCultureProjectCommentList(cultureProjectComment);
        ExcelUtil<CultureProjectComment> util = new ExcelUtil<CultureProjectComment>(CultureProjectComment.class);
        util.exportExcel(response, list, "文化评论数据");
    }

    /**
     * 获取文化评论详细信息
     */
    @RequiresPermissions("culture:projectComment:query")
    @GetMapping(value = "/{id}")
    public AjaxResult getInfo(@PathVariable("id") Long id)
    {
        return success(cultureProjectCommentService.selectCultureProjectCommentById(id));
    }

    /**
     * 新增文化评论
     */
    @RequiresPermissions("culture:projectComment:add")
    @Log(title = "文化评论", businessType = BusinessType.INSERT)
    @PostMapping
    public AjaxResult add(@RequestBody CultureProjectComment cultureProjectComment)
    {
        return toAjax(cultureProjectCommentService.insertCultureProjectComment(cultureProjectComment));
    }

    /**
     * 修改文化评论
     */
    @RequiresPermissions("culture:projectComment:edit")
    @Log(title = "文化评论", businessType = BusinessType.UPDATE)
    @PutMapping
    public AjaxResult edit(@RequestBody CultureProjectComment cultureProjectComment)
    {
        return toAjax(cultureProjectCommentService.updateCultureProjectComment(cultureProjectComment));
    }

    /**
     * 删除文化评论
     */
    @RequiresPermissions("culture:projectComment:remove")
    @Log(title = "文化评论", businessType = BusinessType.DELETE)
	@DeleteMapping("/{ids}")
    public AjaxResult remove(@PathVariable Long[] ids)
    {
        return toAjax(cultureProjectCommentService.deleteCultureProjectCommentByIds(ids));
    }
}
